//
//  AXYpjTableViewCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/16.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXYpjTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@implementation AXYpjTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.font = FONT_FOURTEEN;;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 评价可得积分*/
    self.integralLabel = [[UILabel alloc]init];
    self.integralLabel.textColor = COLOR_GREEN;
    self.integralLabel.font = FONT_TWELVE;
    self.integralLabel.text = @"评价可得44积分";
    [self.contentView addSubview:self.integralLabel];
    
    
    /** 查看评价 */
    self.checkButton = [[UIButton alloc]init];
    self.checkButton.titleLabel.font = FONT_FOURTEEN;;
    self.checkButton.backgroundColor = COLOR_ORG;
    [self.checkButton setTitle:@"查看评价" forState:UIControlStateNormal];
    [self.checkButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.contentView addSubview:self.checkButton];
    /** 追加评价 */
    self.addButton = [[UIButton alloc]init];
    self.addButton.titleLabel.font = FONT_FOURTEEN;;
    self.addButton.backgroundColor = COLOR_ORG;
    [self.addButton setTitle:@"追加评价" forState:UIControlStateNormal];
    [self.addButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.contentView addSubview:self.addButton];
    
    if (SCREEN_WIDTH <= 375) {
        self.integralLabel.font = [UIFont systemFontOfSize:10];
        self.checkButton.titleLabel.font = [UIFont systemFontOfSize:8];
        self.addButton.titleLabel.font = [UIFont systemFontOfSize:8];
    }
    
}

- (void)setlayout {
    
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.contentView,10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    /** 平均可得44积分 */
    self.integralLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productNameLabel, 10)
    .widthIs(100)
    .heightIs(30);
    
    
    /** 追加评价 */
    self.addButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productNameLabel, 10)
    .widthIs(60)
    .heightIs(25);
    
    /** 查看评价 */
    self.checkButton.sd_layout
    .rightSpaceToView(self.addButton, 10)
    .topSpaceToView(self.productNameLabel, 10)
    .widthIs(60)
    .heightIs(25);
    if (SCREEN_WIDTH <= 375) {
        
        /** 平均可得44积分 */
        self.integralLabel.sd_layout
        .leftSpaceToView(self.productImageView, 10)
        .topSpaceToView(self.productNameLabel, 10)
        .widthIs(100)
        .heightIs(20);
        
        /** 追加评价 */
        self.addButton.sd_layout
        .rightSpaceToView(self.contentView, 10)
        .topSpaceToView(self.productNameLabel, 10)
        .widthIs(50)
        .heightIs(20);
        
        /** 查看评价 */
        self.checkButton.sd_layout
        .rightSpaceToView(self.addButton, 10)
        .topSpaceToView(self.productNameLabel, 10)
        .widthIs(50)
        .heightIs(20);
    }
    
    
    /** cell b自动布局第一步 */
    [self setupAutoHeightWithBottomView:self.integralLabel bottomMargin:10];
    
    
    
}


@end

